// DlgEditText.cpp : implementation file
//

#include "stdafx.h"
#include "Celsus.h"
#include "DlgEditText.h"


// CDlgEditText dialog

IMPLEMENT_DYNAMIC(CDlgEditText, CDialog)

CDlgEditText::CDlgEditText(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgEditText::IDD, pParent)
	, m_szText(_T(""))
	, m_szTitle(_T(""))
	, m_szLabel(_T(""))
{
	m_bShowOpenButton = FALSE;
}

CDlgEditText::~CDlgEditText()
{
}

void CDlgEditText::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT_TEXT, m_szText);
	DDX_Text(pDX, IDC_STATIC_LABEL, m_szLabel);
}


BEGIN_MESSAGE_MAP(CDlgEditText, CDialog)
	ON_BN_CLICKED(IDC_BUTTON_OPEN, &CDlgEditText::OnBnClickedButtonOpen)
END_MESSAGE_MAP()


// CDlgEditText message handlers

BOOL CDlgEditText::OnInitDialog()
{
	CDialog::OnInitDialog();

	// set title
	if( !m_szTitle.IsEmpty() )
		SetWindowText( m_szTitle );

	// show open button
	if( m_bShowOpenButton )
		GetDlgItem( IDC_BUTTON_OPEN )->ShowWindow( SW_NORMAL );
	else
		GetDlgItem( IDC_BUTTON_OPEN )->ShowWindow( SW_HIDE );

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgEditText::OnOK()
{
	// TODO: Add your specialized code here and/or call the base class

	CDialog::OnOK();
}

void CDlgEditText::OnCancel()
{
	// TODO: Add your specialized code here and/or call the base class

	CDialog::OnCancel();
}

void CDlgEditText::OnBnClickedButtonOpen()
{
	// update data
	UpdateData();

	// open text
	ShellExecute( NULL, _T("open"), m_szText, NULL, NULL, SW_SHOWNORMAL );
}
